package com.joysuch.wwyt.edu.controller;

import com.joysuch.wwyt.core.support.Context;
import com.joysuch.wwyt.edu.bean.EduVideoBreakpointResumeParam;
import com.joysuch.wwyt.edu.entity.EduVideoBreakpointResume;
import com.joysuch.wwyt.core.common.ajax.ResultBean;
import com.joysuch.wwyt.edu.service.EduVideoBreakpointResumeService;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/edu/video/breakpoint/resume")
@Api(tags = "教育视频断点续传")
public class EduVideoBreakpointResumeController {

    private static final Logger logger = LoggerFactory.getLogger(EduVideoBreakpointResumeController.class);

    @Autowired
    private EduVideoBreakpointResumeService service;

    /**
     * 断点续传
     * @param entity
     * @return
     */
    @PostMapping("eduVideoBreakpointResume")
    public ResultBean eduVideoBreakpointResume(@RequestBody @Valid EduVideoBreakpointResume entity) {
        Long currentUserId = Context.getCurrentUserId();
        entity.setUserId(currentUserId);
        service.add(entity);
        return ResultBean.success("");

    }

    /**
     * 获取断点续传
     * @param
     * @return
     */
    @PostMapping("getEduVideoBreakpointResume")
    public ResultBean getEduVideoBreakpointResume(@RequestBody EduVideoBreakpointResumeParam bean) {
        Long currentUserId = Context.getCurrentUserId();
        bean.setUserId(currentUserId);
        String eduVideoBreakpointResume = service.getEduVideoBreakpointResume(bean);
        return ResultBean.success(eduVideoBreakpointResume);

    }
}
